package com.ych.controller;

import com.ych.beans.Message;
import com.ych.beans.PipeModel;
import com.ych.service.PipeModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/model/pipe")
public class PipeModelController {
    @Autowired
    PipeModelService service;
    @PostMapping("/upload")
    public Message upload(@RequestBody MultipartFile file){
        return service.upload(file);
    }

    @PostMapping
    public Message addPipeModel(@RequestBody PipeModel p){
        return service.addPipeModel(p);
    }

    @PutMapping
    public Message updatePipeModel(@RequestBody PipeModel pipe){
        return service.updatePipeModel(pipe);
    }

    @DeleteMapping("/{pipeId}")
    public Message deletePipeModel(@PathVariable Integer pipeId){
        return service.deletePipeModel(pipeId);
    }
    @GetMapping
    public Message selectPipeModel(@RequestParam Integer pageNo, @RequestParam(required = false) String key){
        return service.selectPipeModel(pageNo,key);
    }
}
